package cn.iocoder.yudao.module.enterprise.service.praxisProjectRecord;

import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.enterprise.controller.admin.praxisProject.vo.EnterpriseProjectRecordVO;
import cn.iocoder.yudao.module.enterprise.dal.dataobject.enterpriseProjectRecord.EnterpriseProjectRecordDO;
import cn.iocoder.yudao.module.enterprise.dal.mysql.praxisProjectRecord.EnterpriseProjectRecordMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 实践项目记录 Service 实现类
 *
 * @author 管理员
 */
@Service
@Validated
public class EnterpriseProjectRecordServiceImpl implements EnterpriseProjectRecordService {

    @Resource
    private EnterpriseProjectRecordMapper enterpriseProjectRecordMapper;

    @Override
    public void saveProjectRecord(Long projectId,Integer recordType) {
        EnterpriseProjectRecordDO recordDO=new EnterpriseProjectRecordDO();
        LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
        recordDO.setCreateTime(new Date());
        recordDO.setCreator(loginUser.getUsername());
        recordDO.setProjectId(projectId);
        recordDO.setRecordType(recordType);
        recordDO.setUserId(loginUser.getId());
        recordDO.setRecordTime(new Date());
        enterpriseProjectRecordMapper.insert(recordDO);
    }

    @Override
    public List<EnterpriseProjectRecordVO> getPraxisProjectRecordList(Long projectId) {
        return enterpriseProjectRecordMapper.getPraxisProjectRecordList(projectId);
    }
}
